﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace HamcoWcs.DAL.Migrations
{
    public partial class A20 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AlterColumn<string>(
                name: "MessageType",
                table: "communication_log",
                type: "varchar(30)",
                maxLength: 30,
                nullable: true,
                defaultValue: "",
                comment: "消息类型",
                oldClrType: typeof(string),
                oldType: "varchar(20)",
                oldMaxLength: 20,
                oldNullable: true,
                oldDefaultValue: "",
                oldComment: "消息类型")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "MessageName",
                table: "communication_log",
                type: "varchar(50)",
                maxLength: 50,
                nullable: false,
                comment: "消息名称",
                oldClrType: typeof(string),
                oldType: "varchar(30)",
                oldMaxLength: 30,
                oldComment: "消息名称")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateTable(
                name: "pallet_info",
                columns: table => new
                {
                    Id = table.Column<long>(type: "bigint", nullable: false, comment: "主键Id")
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    UnitId = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false, comment: "托盘号")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    MaterialInfo = table.Column<string>(type: "varchar(10240)", maxLength: 10240, nullable: true, defaultValue: "", comment: "物料信息")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    MachineName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, defaultValue: "", comment: "设备名")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    PortName = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, defaultValue: "", comment: "设备名Port口")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    Size = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, defaultValue: "", comment: "尺寸")
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    SettingCode = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true, defaultValue: "", comment: "尺寸代码")
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_pallet_info", x => x.Id);
                },
                comment: "托盘信息")
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_pallet_info_UnitId",
                table: "pallet_info",
                column: "UnitId",
                unique: true);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "pallet_info");

            migrationBuilder.AlterColumn<string>(
                name: "MessageType",
                table: "communication_log",
                type: "varchar(20)",
                maxLength: 20,
                nullable: true,
                defaultValue: "",
                comment: "消息类型",
                oldClrType: typeof(string),
                oldType: "varchar(30)",
                oldMaxLength: 30,
                oldNullable: true,
                oldDefaultValue: "",
                oldComment: "消息类型")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.AlterColumn<string>(
                name: "MessageName",
                table: "communication_log",
                type: "varchar(30)",
                maxLength: 30,
                nullable: false,
                comment: "消息名称",
                oldClrType: typeof(string),
                oldType: "varchar(50)",
                oldMaxLength: 50,
                oldComment: "消息名称")
                .Annotation("MySql:CharSet", "utf8mb4")
                .OldAnnotation("MySql:CharSet", "utf8mb4");
        }
    }
}
